<?php
$params = array_merge(
    require(__DIR__ . '/../../common/config/params.php'),
    require(__DIR__ . '/../../common/config/params-local.php'),
    require(__DIR__ . '/params.php'),
    require(__DIR__ . '/params-local.php')
);

return [
    'id' => 'app-api',
    'basePath' => dirname(__DIR__),
    'bootstrap' => ['log'],
    'controllerNamespace' => 'api\controllers',
    "modules" => [
        'scenarios' => [
            'class' => 'api\modules\scenarios\Module',
        ]
    ],
    'components' => [
       'urlManager' => [
           'enablePrettyUrl' => true,
           'showScriptName' => false,
           'enableStrictParsing' => false,
           'rules' => [
//                 '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
                '<controller:\w+>/<action:\w+>' => '<controller>/<action>',
               // '<ns:\w+>/<controller:[\w|-]+>/<action:\w+>' => '<ns>/<controller>/<action>',
           ]
       ],
        'user' => [
            'identityClass' => 'api\models\User',
            // 允许使用auth_key来自动登录
            'enableAutoLogin' => true,
            'identityCookie' => ['name' => '_identity-api', 'httpOnly' => true],
            // 设为null避免跳转
            // 'loginUrl' => null,
            // 'regenerateId' => true,
        ],
        'session' => [
            'class'=>'yii\redis\Session',
            'keyPrefix'=>'funfind',
            'redis' => 'redis',
            'cookieParams' => [
              'path' => '/',
              'httponly' => true,
              'domain' => "",
            ],
        ],
       'redis' => [ 
          'class' => 'yii\redis\Connection',
          'hostname' => 'localhost',
          'port' => 6379,
          'database' => 0,
        ],
        'redis_01' => [
          'class' => 'yii\redis\Connection',
          'hostname' => 'localhost',
          'port' => 6379,
          'database' => 1,
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
            ],
        ],
        'request' => [
            'cookieValidationKey' => 'fcuVvgFv0Vex88Qm5N2-h6MM5anM4HEd',
        ],
    ],
    'params' => $params,
];
